home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig05_07.jar
/
Ch05
/
Fig05_07
/
Fig05_07.cpp
next >
Wrap
C/C++ Source or Header
|
1997-10-14
|
487b
|
24 lines
// Fig. 5.7: fig05_07.cpp
// Cube a variable using call-by-reference
// with a pointer argument
#include <iostream.h>
void cubeByReference( int * ); // prototype
int main()
{
int number = 5;
cout << "The original value of number is " << number;
cubeByReference( &number );
cout << "\nThe new value of number is " << number << endl;
return 0;
}
void cubeByReference( int *nPtr )
{
*nPtr = *nPtr * *nPtr * *nPtr; // cube number in main
}